<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03.10小练习</title>
</head>

<body>
    <script>
        // 1. 运行以下代码，会输出什么？
        /* 
        var sum = 0;
        for (var i = 0; i <= 9; i++) { sum += i; } console.log(sum); //45
        console.log(i);//10 */

        // 2.用while,do...while, for三种循环语句实现1到100的累加和

        /*
        var i = 1;
        var num = 0;
        while (i <= 100) {
            num += i;//累加i
            i++;
        }
        console.log(num); */

        /*
        var i = 1;
        var num = 0;
        do {
            num += i;
            i++;
        } while (i <= 100);
        console.log(num); */

        /*
        var num = 0
        for (var i = 1; i <= 100; i++) {
            num += i;
        }
        console.log(num); */

    </script>
</body>

</html>